How to read MAC address with python

Posted by getjoefree on Super User See other posts from Super User or by getjoefree
Published on 2012-06-18T08:42:29Z Indexed on 2012/07/07 3:18 UTC
Read the original article Hit count: 831

Filed under:
|
|
|

Earlier, I could read MAC address with awk tools in Windows or Windows PE 4.0, but now it don't support Windows PE 4.0 64-bit. I want to get this result "set mac=A4BADB9D1E8E" with python 2.6, who could help to me.

As follows:
ipconfig -all|sed -nrf getmac.sed | sed -e "s/-//g" > D:\LOG\WINMAC.BAT
getmac.sed:
/Realtek/ {
n;
s/.*: ([-0-9A-F]+)/set winmac=\1/p;
}
and "ipconfig -all" command log as bellows
ipconfig -all >mac.log
Ethernet adapter Ethernet:  
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : WKSCN.WISTRON
Description . . . . . . . . . . . : Realtek PCIe FE Family Controller
Physical Address. . . . . . . . . : 24-B6-FD-1F-41-E7
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
---------------------------------------

we can get Physical Address when plug in lan cable, but not plug the network cable, it is impossible to obtain IP address.

© Super User or respective owner

Related posts about Windows

Related posts about python